From e6863321667c6344fc3203e18b9ceef251645cb0 Mon Sep 17 00:00:00 2001 From: "kaf24@freefall.cl.cam.ac.uk" Date: Sat, 4 Sep 2004 06:28:25 +0000 Subject: [PATCH] bitkeeper revision 1.1159.69.8 (413960891Us2H0wgOni9gC4Dvk3uCw) Fix I/O mapping in Xen/Linux. --- linux-2.6.8.1-xen-sparse/arch/xen/Kconfig | 3 +- .../arch/xen/i386/mm/ioremap.c | 32 +++++++++++++++---- .../include/asm-xen/asm-i386/io.h | 6 ++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig b/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig index 9f4c1d8002..5beabc830d 100644 --- a/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig +++ b/linux-2.6.8.1-xen-sparse/arch/xen/Kconfig @@ -26,13 +26,12 @@ menu "XEN" config XEN_PRIVILEGED_GUEST bool "Privileged Guest (domain 0)" default n + select XEN_PHYSDEV_ACCESS help Support for privileged operation (domain 0) config XEN_PHYSDEV_ACCESS bool "Device-driver domain (physical device access)" - default y if XEN_PRIVILEGED_GUEST - default n help Device-driver domain (physical device access) diff --git a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c index eed6379821..1efdacd8c2 100644 --- a/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c +++ b/linux-2.6.8.1-xen-sparse/arch/xen/i386/mm/ioremap.c @@ -17,6 +17,25 @@ #include #include +#ifndef CONFIG_XEN_PHYSDEV_ACCESS + +void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags) +{ return NULL; } + +void *ioremap_nocache (unsigned long phys_addr, unsigned long size) +{ return NULL; } + +void iounmap(void *addr) +{ } + +void __init *bt_ioremap(unsigned long phys_addr, unsigned long size) +{ return NULL; } + +void __init bt_iounmap(void *addr, unsigned long size) +{ } + +#else + static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, unsigned long phys_addr, unsigned long flags) { @@ -133,11 +152,11 @@ void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flag /* * Don't allow anybody to remap normal RAM that we're using.. */ - if (phys_addr < virt_to_phys(high_memory)) { + if (machine_to_phys(phys_addr) < virt_to_phys(high_memory)) { char *t_addr, *t_end; struct page *page; - t_addr = __va(phys_addr); + t_addr = bus_to_virt(phys_addr); t_end = t_addr + (size - 1); for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++) @@ -200,8 +219,8 @@ void *ioremap_nocache (unsigned long phys_addr, unsigned long size) /* Guaranteed to be > phys_addr, as per __ioremap() */ last_addr = phys_addr + size - 1; - if (last_addr < virt_to_phys(high_memory)) { - struct page *ppage = virt_to_page(__va(phys_addr)); + if (machine_to_phys(last_addr) < virt_to_phys(high_memory)) { + struct page *ppage = virt_to_page(bus_to_virt(phys_addr)); unsigned long npages; phys_addr &= PAGE_MASK; @@ -237,8 +256,8 @@ void iounmap(void *addr) return; } - if (p->flags && p->phys_addr < virt_to_phys(high_memory)) { - change_page_attr(virt_to_page(__va(p->phys_addr)), + if (p->flags && machine_to_phys(p->phys_addr) < virt_to_phys(high_memory)) { + change_page_attr(virt_to_page(bus_to_virt(p->phys_addr)), p->size >> PAGE_SHIFT, PAGE_KERNEL); global_flush_tlb(); @@ -316,6 +335,7 @@ void __init bt_iounmap(void *addr, unsigned long size) } } +#endif /* CONFIG_XEN_PHYSDEV_ACCESS */ #if defined(CONFIG_XEN_PRIVILEGED_GUEST) diff --git a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h index 81de51c1b5..db076b4370 100644 --- a/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h +++ b/linux-2.6.8.1-xen-sparse/include/asm-xen/asm-i386/io.h @@ -128,12 +128,12 @@ extern void bt_iounmap(void *addr, unsigned long size); /* * ISA I/O bus memory addresses are 1:1 with the physical address. */ -#define isa_virt_to_bus(_x) BUG() // should be (void *)((FIX_ISAMAP_BEGIN - __virt_to_fix((_x))) << PAGE_SHIFT) -#define isa_page_to_bus(_x) BUG() // page_to_phys(_x) +#define isa_virt_to_bus(_x) isa_virt_to_bus_is_UNSUPPORTED->x +#define isa_page_to_bus(_x) isa_page_to_bus_is_UNSUPPORTED->x #ifdef CONFIG_XEN_PRIVILEGED_GUEST #define isa_bus_to_virt(_x) (void *)__fix_to_virt(FIX_ISAMAP_BEGIN - ((_x) >> PAGE_SHIFT)) #else -#define isa_bus_to_virt(_x) (void *)0L /* XXXcl */ +#define isa_bus_to_virt(_x) isa_bus_to_virt_needs_PRIVILEGED_BUILD #endif /* -- 2.30.2